package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BEPictureOld;
import com.ruoyi.system.service.IBEPictureOldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 电子旧图片Controller
 * 
 * @author ruoyi
 * @date 2023-09-22
 */
@RestController
@RequestMapping("/system/oldepicture")
public class BEPictureOldController extends BaseController
{
    @Autowired
    private IBEPictureOldService bEPictureOldService;

    /**
     * 查询电子旧图片列表
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:list')")
    @GetMapping("/list")
    public TableDataInfo list(BEPictureOld bEPictureOld)
    {
        startPage();
        List<BEPictureOld> list = bEPictureOldService.selectBEPictureOldList(bEPictureOld);
        return getDataTable(list);
    }

    /**
     * 获取二进制文件
     */
    @PostMapping("/getOldPic")
    public ResponseEntity<byte[]> getOldPic(@RequestBody BEPictureOld bEPictureOld)
    {
        return bEPictureOldService.getOldPic(bEPictureOld);
    }

    /**
     * 下载二进制文件
     */
    @PostMapping("/downloadOldPic")
    public ResponseEntity<byte[]> downloadOldPic(@RequestBody BEPictureOld bEPictureOld)
    {
        return bEPictureOldService.downloadOldPic(bEPictureOld);
    }

    /**
     * 批量下载文件
     */
    @GetMapping("/downloadOldMore/{ids}")
    public ResponseEntity<byte[]> downloadMore(@PathVariable String[] ids)
    {
        return bEPictureOldService.downloadMore(ids);
    }

    /**
     * 导出电子旧图片列表
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:export')")
    @Log(title = "电子旧图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BEPictureOld bEPictureOld)
    {
        List<BEPictureOld> list = bEPictureOldService.selectBEPictureOldList(bEPictureOld);
        ExcelUtil<BEPictureOld> util = new ExcelUtil<BEPictureOld>(BEPictureOld.class);
        util.exportExcel(response, list, "电子旧图片数据");
    }

    /**
     * 获取电子旧图片详细信息
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bEPictureOldService.selectBEPictureOldById(id));
    }

    /**
     * 新增电子旧图片
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:add')")
    @Log(title = "电子旧图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BEPictureOld bEPictureOld)
    {
        return toAjax(bEPictureOldService.insertBEPictureOld(bEPictureOld));
    }

    /**
     * 修改电子旧图片
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:edit')")
    @Log(title = "电子旧图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BEPictureOld bEPictureOld)
    {
        return toAjax(bEPictureOldService.updateBEPictureOld(bEPictureOld));
    }

    /**
     * 删除电子旧图片
     */
//    //@PreAuthorize("@ss.hasPermi('system:oldepicture:remove')")
    @Log(title = "电子旧图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bEPictureOldService.deleteBEPictureOldByIds(ids));
    }
}
